import streamlit as st
import requests
import time

text = st.text_input('请输入用户意图文本:')


# 1. 准备URL
url = 'http://192.168.109.34:10086/predict'
if st.button('基于LLM模型获取分类!'):
    # 2. 获取任务开始时间
    start_time = time.time()
    try:
        # 3. 发送请求, 获取数据.
        r = requests.post(url, json={'input_text': text})
        print(f'r: {r.json()}')
        # 4. 计算耗时.
        total_time = (time.time() - start_time) * 1000
        st.write('耗时: ', total_time, 'ms')
        # 5. 显示预测结果到网页.
        st.write('预测结果: ', r.json())

    except:
        print(f'出问题了')

